---------------------------------------------------------------------------------------
-- Custom Firmware Init Script
---------------------------------------------------------------------------------------
-- This file must be loaded after the init_base.lua ;
---------------------------------------------------------------------------------------
--[[
--	GetCFWVersion() 

	Get the User Version of Customized Firmware.
	
	Return value --> For GetCFWVersion()
	#nResult : Version of CFW.
	

--	GetCFWVendor()

	Get the Vendor Information of Customized Firmware.
	
	Return value --> For GetCFWVendor()
	#strVendor : Vendor information of CFW.

--	CFWCmd() 
	
	Data transmission between host and bridgeboard customized firmware
	 
	Parameter :
	@pCmdIn : Command data between host and bridge board.
	@buffer : Transaction data buffer between host and bridge board.
	@buffer_size : Transaction size of data buffer between host and bridge board.
	 
	Return value --> For CFWCmd()
	#cmd : Command result, if the command is right to excute then return value is zero. 
	#dataOut : Result of transaction data.
	#bResult : If the function succeeds, return TRUE. Otherwise, return FALSE.
]]--

-----------------------------------------------------------------------------------------
function GetCFWVersion()
	nResult  = RTBB_EXTCFW_GetCFWVersion(g_hBridgeBoard);
	dbgprintf ("Firmware Version  = 0x%x\n",nResult );
	return nResult ;
end

function GetCFWVendor()
	 strVendor  = RTBB_EXTCFW_GetCFWVendor (g_hBridgeBoard);
	 dbgprintf ("Firmware Vendor =  %s\n",strVendor );
	 return strVendor ;
end

function CFWCmd(pCmdIn, buffer, buffer_size )

	if ( buffer == nil ) then buffer = {} end;
	if ( buffer_size == nil) then buffer_size = #buffer end;
	
	local dataOut = {};
	nResult, cmd = RTBB_EXTCFW_Transact(g_hBridgeBoard,pCmdIn, buffer_size, buffer, dataOut);
	bResult = resultMsg( "RTBB_EXTCFW_Transact", nResult );
	dbgprintf("Command: %d\n", cmd)
	
	return cmd,dataOut,bResult;
end	